# 设置文件共享
mkdir -p /data/media/tv
mkdir -p /data/media/movie
mkdir -p /data/media/av

if command -v samba >/dev/null 2>&1; then
    echo "smb is installed."
else
    echo "smb未安装,开始安装smb..."
    read -p "请输入你要共享的目录: " path
    mkdir -p $path   # 共享目录，可修改。和smb.conf的path配置对应
    apt update
    apt install samba
    systemctl start smb
    systemctl enable smb
    read -p "请输入你的共享用户名称: " user
    cat >> /etc/samba/smb.conf <<EOF
[share]
    comment = share
    path = $path
    valid users = $user
    browseable = yes
    read only = yes
EOF
    smbpasswd -a $user   # 共享用户名
    systemctl restart samba
fi